﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControl_ucDienthoai : System.Web.UI.UserControl
{
    CategoryController cateControl;
    ProductsController productControl;

    DataTable dtCate;
    DataTable dtEnableCate;
    DataTable testview;

    public List<Category> listCate = new List<Category>();
    public List<DanhmucPhukien> listDanhmucphukien = new List<DanhmucPhukien>();
    public List<Danhmucsanpham> listDanhmucsanpham = new List<Danhmucsanpham>();

    protected void Page_Load(object sender, EventArgs e)
    {
        cateControl = new CategoryController();
        productControl = new ProductsController();

        dtCate = cateControl.getAllCategory();
        dtEnableCate = cateControl.getEnableCategory();

        parentDataList.DataSource = dtEnableCate;
        parentDataList.DataBind();
    }

    protected void parentDataList_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        DataRowView dtrv = (DataRowView)e.Item.DataItem;
        int id = (int)dtrv.Row["category_id"];
        testview = productControl.GetProductByCateId(id);
        DataList dl = (DataList)e.Item.FindControl("dtlTest");
        dl.DataSource = testview;
        dl.DataBind();
    }
}